home *** CD-ROM | disk | FTP | other *** search
Java Source | 1997-06-19 | 2.6 KB | 151 lines |
- package symantec.itools.demo;
-
-
- import java.applet.Applet;
- import java.awt.Component;
- import java.awt.FlowLayout;
- import java.awt.Font;
- import java.awt.Graphics;
- import java.awt.LayoutManager;
- import symantec.itools.awt.util.Util;
-
-
- /**
- *
- *
- *
- * @see
- *
- * @version 1.0, Nov 26, 1996
- *
- * @author Symantec
- *
- */
-
-
- public abstract class Demo
- extends Applet
- {
- protected String title;
- protected boolean isApplet;
- protected DemoFrame frame;
- protected int xPos;
- protected int yPos;
- protected int width;
- protected int height;
-
- public Demo(String s, int x, int y, int w, int h)
- {
- title = s;
- xPos = x;
- yPos = y;
- width = w;
- height = h;
- }
-
- public void init()
- {
- isApplet = true;
- setup();
- frame.show();
- }
-
- protected void driver()
- {
- isApplet = false;
- setup();
- frame.show();
- }
-
- protected void setup()
- {
- frame = new DemoFrame(this, title);
- frame.reshape(xPos, yPos, width, height);
- frame.setLayout(new FlowLayout());
- }
-
- public void endDemo()
- {
- if(isApplet)
- {
- stop();
- }
- else
- {
- System.exit(0);
- }
- }
-
- public void cleanup()
- {
- frame.hide();
- frame.dispose();
- }
-
- public void doExit()
- {
- cleanup();
- endDemo();
- }
-
- public void doHelp()
- {
- }
-
- public void doAbout()
- {
- }
-
- public void doRestart()
- {
- cleanup();
- setup();
- }
-
- public Component add(Component c)
- {
- return (frame.add(c));
- }
-
- public synchronized Component add(Component c, int i)
- {
- return (frame.add(c, i));
- }
-
- public synchronized Component add(String s, Component c)
- {
- return (frame.add(s, c));
- }
-
- public void setLayout(LayoutManager manager)
- {
- if(frame != null)
- {
- frame.setLayout(manager);
- }
- }
-
- public Graphics getGraphics()
- {
- return frame.getGraphics();
- }
-
- public Font getFont()
- {
- Font font;
-
- if(frame != null)
- {
- font = frame.getFont();
-
- font = (font == null) ? Util.getDefaultFont() : font;
- }
- else
- {
- font = Util.getDefaultFont();
- }
-
- return font;
- }
- }
-